{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "import networkx as nx\n",
    "import math\n",
    "import random\n",
    "\n",
    "def arbitrary_element(iterable):\n",
    "    \"\"\"Returns an arbitrary element of `iterable` without removing it.\n",
    "\n",
    "    This is most useful for \"peeking\" at an arbitrary element of a set,\n",
    "    but can be used for any list, dictionary, etc., as well::\n",
    "\n",
    "        >>> arbitrary_element({3, 2, 1})\n",
    "        1\n",
    "        >>> arbitrary_element('hello')\n",
    "        'h'\n",
    "\n",
    "    This function raises a :exc:`ValueError` if `iterable` is an\n",
    "    iterator (because the current implementation of this function would\n",
    "    consume an element from the iterator)::\n",
    "\n",
    "        >>> iterator = iter([1, 2, 3])\n",
    "        >>> arbitrary_element(iterator)\n",
    "        Traceback (most recent call last):\n",
    "            ...\n",
    "        ValueError: cannot return an arbitrary item from an iterator\n",
    "\n",
    "    \"\"\"\n",
    "    if is_iterator(iterable):\n",
    "        raise ValueError('cannot return an arbitrary item from an iterator')\n",
    "    # Another possible implementation is ``for x in iterable: return x``.\n",
    "    return next(iter(iterable))\n",
    "\n",
    "def is_iterator(obj):\n",
    "    \"\"\"Returns True if and only if the given object is an iterator\n",
    "    object.\n",
    "\n",
    "    \"\"\"\n",
    "    has_next_attr = hasattr(obj, '__next__') or hasattr(obj, 'next')\n",
    "    return iter(obj) is obj and has_next_attr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "def ramsey_R2(G):\n",
    "    r\"\"\"Approximately computes the Ramsey number `R(2;s,t)` for graph.\n",
    "\n",
    "    Parameters\n",
    "    ----------\n",
    "    G : NetworkX graph\n",
    "        Undirected graph\n",
    "\n",
    "    Returns\n",
    "    -------\n",
    "    max_pair : (set, set) tuple\n",
    "        Maximum clique, Maximum independent set.\n",
    "    \"\"\"\n",
    "    if not G:\n",
    "        return set(), set()\n",
    "\n",
    "    node = arbitrary_element(G)\n",
    "    nbrs = nx.all_neighbors(G, node)\n",
    "    nnbrs = nx.non_neighbors(G, node)\n",
    "    c_1, i_1 = ramsey_R2(G.subgraph(nbrs).copy())\n",
    "    c_2, i_2 = ramsey_R2(G.subgraph(nnbrs).copy())\n",
    "\n",
    "    c_1.add(node)\n",
    "    i_2.add(node)\n",
    "    # Choose the larger of the two cliques and the larger of the two\n",
    "    # independent sets, according to cardinality.\n",
    "    return max(c_1, c_2, key=len), max(i_1, i_2, key=len)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Import system requirements\n",
    "import sys, os\n",
    "\n",
    "# Import libraries\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Import data\n",
    "\n",
    "dataset = 'sp500' # values: 'asset_class','ftse','sectors','sp100'\n",
    "\n",
    "corr_tensor = np.load('%s_corr.npy' % (dataset)) #list of correlation matrices for each date\n",
    "dates = np.load('%s_dates.npy' % (dataset)) #list of timestamps\n",
    "nodes = np.load('%s_nodes.npy' % (dataset)) #list of tickers\n",
    "\n",
    "num_examples = corr_tensor.shape[0] #number of dates\n",
    "dim = corr_tensor.shape[1] #number of assets\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "def make_graph(corr_mat, node_labels, graph_type):\n",
    "\n",
    "    G = nx.Graph()\n",
    "    G.add_nodes_from(node_labels)\n",
    "    dim = corr_mat.shape[0]\n",
    "\n",
    "    if not dim == len(node_labels):\n",
    "        raise ValueError('number node labels not = corr matrix dimensions')\n",
    "\n",
    "    if graph_type=='signed':\n",
    "        for i in range(dim):\n",
    "            for j in range(i+1, dim):\n",
    "                if corr_mat[i,j] < 0:\n",
    "                    G.add_edge(node_labels[i], node_labels[j], sign=-1)\n",
    "                elif corr_mat[i,j] > 0:\n",
    "                    G.add_edge(node_labels[i], node_labels[j], sign=1)\n",
    "    \n",
    "    if graph_type=='corr':\n",
    "        for i in range(dim):\n",
    "            for j in range(i+1, dim):\n",
    "                if corr_mat[i,j] != 0.000:\n",
    "                    G.add_edge(node_labels[i], node_labels[j])\n",
    "    \n",
    "    if graph_type=='uncorr':\n",
    "        for i in range(dim):\n",
    "            for j in range(i+1, dim):\n",
    "                if corr_mat[i,j] == 0.000:\n",
    "                    G.add_edge(node_labels[i], node_labels[j])\n",
    "    \n",
    "    density = (2*G.number_of_edges())/(G.number_of_nodes()*(G.number_of_nodes() - 1))\n",
    "                \n",
    "    return G, density\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [],
   "source": [
    "corr_mat = corr_tensor[int(num_examples/2), :, :].copy() #take the correlation matrix for a specific date (for visualization)\n",
    "corr_mat[(corr_mat > -1*0.9) & (corr_mat < 0.9)] = 0 #arbitrary threshold, for visualization purposes\n",
    "G, density = make_graph(corr_mat, nodes, 'corr')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "0.1353352832366127\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "0.049787068367863944\n",
      "0.1353352832366127\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "0.049787068367863944\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "0.006737946999085467\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.0024787521766663585\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.0009118819655545162\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "1.0\n",
      "0.36787944117144233\n",
      "whoa\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "1.0\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "0.0024787521766663585\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.1353352832366127\n",
      "eh\n",
      "eh\n",
      "0.1353352832366127\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "1.0\n",
      "0.1353352832366127\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "0.049787068367863944\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "0.049787068367863944\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.1353352832366127\n",
      "eh\n",
      "eh\n",
      "0.1353352832366127\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.1353352832366127\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.1353352832366127\n",
      "eh\n",
      "eh\n",
      "0.049787068367863944\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "1.0\n",
      "whoa\n",
      "whoa\n",
      "0.36787944117144233\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.1353352832366127\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "whoa\n",
      "0.1353352832366127\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "1.0\n",
      "0.1353352832366127\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.1353352832366127\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.1353352832366127\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.049787068367863944\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.01831563888873418\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.006737946999085467\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.0024787521766663585\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "1.0\n",
      "0.1353352832366127\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.049787068367863944\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "whoa\n",
      "0.1353352832366127\n",
      "0.1353352832366127\n",
      "eh\n",
      "whoa\n",
      "0.006737946999085467\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.1353352832366127\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "1.0\n",
      "0.1353352832366127\n",
      "whoa\n",
      "whoa\n",
      "0.36787944117144233\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.006737946999085467\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.0024787521766663585\n",
      "0.049787068367863944\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "0.1353352832366127\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "0.1353352832366127\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.1353352832366127\n",
      "0.1353352832366127\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "0.1353352832366127\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.1353352832366127\n",
      "1.0\n",
      "whoa\n",
      "whoa\n",
      "0.36787944117144233\n",
      "1.0\n",
      "whoa\n",
      "whoa\n",
      "0.36787944117144233\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.1353352832366127\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "0.049787068367863944\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.01831563888873418\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.006737946999085467\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.1353352832366127\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "0.1353352832366127\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.01831563888873418\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.1353352832366127\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.1353352832366127\n",
      "1.0\n",
      "whoa\n",
      "whoa\n",
      "0.0009118819655545162\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.1353352832366127\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.0024787521766663585\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "whoa\n",
      "0.1353352832366127\n",
      "1.0\n",
      "whoa\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.1353352832366127\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.1353352832366127\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.049787068367863944\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.0024787521766663585\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "whoa\n",
      "0.1353352832366127\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.1353352832366127\n",
      "eh\n",
      "eh\n",
      "0.00033546262790251185\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "1.0\n",
      "0.36787944117144233\n",
      "whoa\n",
      "whoa\n",
      "1.0\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "0.1353352832366127\n",
      "whoa\n",
      "whoa\n",
      "4.5399929762484854e-05\n",
      "0.1353352832366127\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "1.0\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.1353352832366127\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.1353352832366127\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.1353352832366127\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "1.0\n",
      "0.1353352832366127\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.1353352832366127\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "whoa\n",
      "0.1353352832366127\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.049787068367863944\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "1.0\n",
      "whoa\n",
      "whoa\n",
      "0.01831563888873418\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "1.0\n",
      "0.1353352832366127\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.1353352832366127\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "0.049787068367863944\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "1.0\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.1353352832366127\n",
      "1.0\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.1353352832366127\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "1.0\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "0.1353352832366127\n",
      "whoa\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "1.0\n",
      "whoa\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.1353352832366127\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "1.0\n",
      "0.1353352832366127\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "1.0\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "0.1353352832366127\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "whoa\n",
      "0.36787944117144233\n",
      "0.36787944117144233\n",
      "eh\n",
      "eh\n",
      "1.0\n",
      "0.1353352832366127\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "0.049787068367863944\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "0.01831563888873418\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "0.006737946999085467\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "0.0024787521766663585\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "0.0009118819655545162\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "0.00033546262790251185\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "0.00012340980408667956\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "4.5399929762484854e-05\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.670170079024566e-05\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "6.14421235332821e-06\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "2.2603294069810542e-06\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "8.315287191035679e-07\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "3.059023205018258e-07\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "1.1253517471925912e-07\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "4.139937718785167e-08\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.522997974471263e-08\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "5.602796437537268e-09\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.061153622438558e-09\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "7.582560427911907e-10\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.7894680928689246e-10\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.026187963170189e-10\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "3.775134544279098e-11\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.3887943864964021e-11\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "5.109089028063325e-12\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.8795288165390832e-12\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "6.914400106940203e-13\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.543665647376923e-13\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "9.357622968840175e-14\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "3.442477108469977e-14\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.2664165549094176e-14\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "4.658886145103398e-15\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.713908431542013e-15\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.713908431542013e-15\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.3195228302435696e-16\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "2.3195228302435696e-16\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "3.1391327920480296e-17\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.1548224173015786e-17\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "4.248354255291589e-18\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.5628821893349888e-18\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "5.74952226429356e-19\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.1151310375910805e-19\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.1151310375910805e-19\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "2.8625185805493937e-20\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.0530617357553812e-20\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "3.873997628687187e-21\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.4251640827409352e-21\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "5.242885663363464e-22\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.9287498479639178e-22\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "7.095474162284704e-23\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.6102790696677047e-23\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "9.602680054508676e-24\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "3.532628572200807e-24\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.2995814250075031e-24\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "4.780892883885469e-25\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.7587922024243116e-25\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "6.47023492564546e-26\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.3802664086944007e-26\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "8.75651076269652e-27\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "3.221340285992516e-27\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.185064864233981e-27\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "4.359610000063081e-28\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.603810890548638e-28\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "5.900090541597061e-29\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.1705220113036395e-29\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "7.984904245686979e-30\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "7.984904245686979e-30\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "1.0806392777072785e-30\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "3.975449735908647e-31\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.462486227251231e-31\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "5.380186160021138e-32\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.9792598779469045e-32\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "7.281290178321643e-33\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.6786369618080778e-33\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "9.854154686111257e-34\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "3.6251409191435593e-34\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.3336148155022614e-34\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "4.906094730649281e-35\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.8048513878454153e-35\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "6.639677199580735e-36\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.4426007377405277e-36\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "8.985825944049381e-37\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "2.4426007377405277e-36\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.2160992992528256e-37\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "4.4737793061811207e-38\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.6458114310822737e-38\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "6.054601895401186e-39\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.2273635617957438e-39\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "8.194012623990515e-40\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "3.0144087850653746e-40\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.1089390193121365e-40\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "4.0795586671775603e-41\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.5007857627073948e-41\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "5.5210822770285325e-42\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.031092662734811e-42\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "2.031092662734811e-42\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.7487850079102147e-43\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.0112214926104486e-43\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "3.720075976020836e-44\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.368539471173853e-44\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "5.0345753587649823e-45\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.8521167695179754e-45\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "6.813556821545298e-46\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.506567475899953e-46\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "2.506567475899953e-46\n",
      "eh\n",
      "eh\n",
      "1.0\n",
      "9.221146422925876e-47\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "3.392270193026015e-47\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "4.590938473882946e-48\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "1.2479464629129513e-47\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "6.213159586848109e-49\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.2856936767186716e-49\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "8.408597124803643e-50\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "3.093350011308561e-50\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.1379798735078682e-50\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "4.1863939993042314e-51\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.5400882849875202e-51\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "5.665668176358939e-52\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.0842828425817514e-52\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "7.667648073722e-53\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.820770088460135e-53\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.0377033238158346e-53\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "3.817497188671175e-54\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "3.817497188671175e-54\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "5.166420632837861e-55\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.9006199352650016e-55\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "6.991989996645917e-56\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.572209372642415e-56\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "9.462629465836378e-57\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "3.4811068399043105e-57\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.2806276389220833e-57\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.2806276389220833e-57\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.733141042341547e-58\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "6.375869581278994e-59\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.3455513385429143e-59\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "8.628801156620959e-60\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "3.1743585474772134e-60\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.1677812485237086e-60\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "4.2960271311739114e-61\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.580420060273613e-61\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "5.814040485895939e-62\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.138865964899539e-62\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "7.868448159078602e-63\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.8946403116483003e-63\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.0648786602415064e-63\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "3.917469664450395e-64\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.4411565509640892e-64\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "5.301718666092324e-65\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.9503933001302485e-65\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "7.175095973164411e-66\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.6395702969591894e-66\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "9.710436457780846e-67\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "9.710436457780846e-67\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.314164668364901e-67\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "4.834541638053336e-68\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.7785284761271306e-68\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "6.542840619051457e-69\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.4069765506104637e-69\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "8.854771883513433e-70\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "8.854771883513433e-70\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.1983630608508849e-70\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "4.408531331463226e-71\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.6218080426054863e-71\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "5.96629836401057e-72\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.194878508014299e-72\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "8.074506789675094e-73\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.970445045520691e-73\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.0927656633766312e-73\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "4.020060215743355e-74\n",
      "eh\n",
      "eh\n",
      "1.0\n",
      "4.020060215743355e-74\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "5.440559879258653e-75\n",
      "eh\n",
      "eh\n",
      "1.0\n",
      "5.440559879258653e-75\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "7.362997122252211e-76\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "2.7086952666810816e-76\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "9.964733010103672e-77\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "3.665820411179563e-77\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "3.665820411179563e-77\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "4.961148436415422e-78\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.8251045143570802e-78\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "6.714184288211594e-79\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.470010363869359e-79\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.470010363869359e-79\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "2.470010363869359e-79\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.2297457485529627e-80\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "1.2297457485529627e-80\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "1.664279891894355e-81\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "6.122543565829638e-82\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.252357905545217e-82\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "8.285961676100547e-83\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "3.0482349509718567e-83\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.1213829703227856e-83\n",
      "whoa\n",
      "eh\n",
      "0.1353352832366127\n",
      "3.0482349509718567e-83\n",
      "eh\n",
      "eh\n",
      "0.1353352832366127\n",
      "1.5176268190534823e-84\n",
      "eh\n",
      "eh\n",
      "0.36787944117144233\n",
      "1.5176268190534823e-84\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "2.0538845540408258e-85\n",
      "eh\n",
      "eh\n",
      "0.1353352832366127\n",
      "5.583037061001886e-85\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.0538845540408258e-85\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.779630478564191e-86\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "3.761820781096061e-87\n",
      "eh\n",
      "eh\n",
      "1.0\n",
      "3.761820781096061e-87\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "5.09107080895011e-88\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "1.8729002841608093e-88\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "6.89001509906914e-89\n",
      "whoa\n",
      "eh\n",
      "1.0\n",
      "2.534694904308355e-89\n",
      "whoa\n",
      "eh\n",
      "0.36787944117144233\n",
      "9.324621449370601e-90\n",
      "eh\n",
      "eh\n",
      "0.049787068367863944\n",
      "9.324621449370601e-90\n",
      "eh\n",
      "eh\n",
      "0.01831563888873418\n",
      "1.2619502849247644e-90\n",
      "eh\n",
      "eh\n",
      "0.049787068367863944\n",
      "1.2619502849247644e-90\n",
      "eh\n",
      "eh\n",
      "0.01831563888873418\n",
      "1.7078639924081707e-91\n",
      "eh\n",
      "eh\n",
      "0.01831563888873418\n",
      "6.282880511239462e-92\n",
      "eh\n",
      "eh\n",
      "0.1353352832366127\n",
      "6.282880511239462e-92\n",
      "eh\n",
      "eh\n",
      "0.049787068367863944\n",
      "8.502954135303866e-93\n",
      "eh\n",
      "eh\n",
      "0.01831563888873418\n",
      "3.1280620156019908e-93\n",
      "eh\n",
      "eh\n",
      "0.01831563888873418\n",
      "3.1280620156019908e-93\n",
      "eh\n",
      "eh\n",
      "0.01831563888873418\n",
      "4.23337158863185e-94\n",
      "eh\n",
      "eh\n",
      "0.01831563888873418\n",
      "1.5573703742969461e-94\n",
      "eh\n",
      "eh\n",
      "0.049787068367863944\n",
      "4.23337158863185e-94\n",
      "eh\n",
      "eh\n",
      "0.01831563888873418\n",
      "2.107671607097867e-95\n",
      "eh\n",
      "eh\n",
      "0.01831563888873418\n",
      "7.753690529920792e-96\n",
      "eh\n",
      "eh\n",
      "0.1353352832366127\n",
      "7.753690529920792e-96\n",
      "eh\n",
      "eh\n",
      "0.01831563888873418\n",
      "1.0493479039958717e-96\n",
      "eh\n",
      "eh\n",
      "0.049787068367863944\n",
      "1.0493479039958717e-96\n",
      "eh\n",
      "eh\n",
      "0.049787068367863944\n",
      "3.860335205164256e-97\n",
      "eh\n",
      "eh\n",
      "0.1353352832366127\n",
      "1.4201379580102718e-97\n",
      "eh\n",
      "eh\n",
      "0.049787068367863944\n",
      "5.22439558379172e-98\n",
      "eh\n",
      "eh\n",
      "0.01831563888873418\n",
      "7.070450560725609e-99\n",
      "eh\n",
      "eh\n",
      "0.01831563888873418\n",
      "2.601073401110048e-99\n",
      "eh\n",
      "eh\n",
      "0.01831563888873418\n",
      "9.568814292462674e-100\n",
      "eh\n",
      "eh\n",
      "0.049787068367863944\n",
      "2.601073401110048e-99\n",
      "eh\n",
      "eh\n",
      "0.049787068367863944\n",
      "3.5201700545844787e-100\n",
      "eh\n",
      "eh\n",
      "0.01831563888873418\n",
      "4.764032113782328e-101\n",
      "eh\n",
      "eh\n",
      "0.01831563888873418\n",
      "1.7525894717410477e-101\n",
      "eh\n",
      "eh\n",
      "0.01831563888873418\n",
      "6.4474163546704995e-102\n",
      "eh\n",
      "eh\n",
      "0.01831563888873418\n",
      "2.371871925555801e-102\n",
      "eh\n",
      "eh\n",
      "0.01831563888873418\n",
      "8.72562918503701e-103\n",
      "eh\n",
      "eh\n",
      "0.01831563888873418\n",
      "3.209979588460643e-103\n",
      "eh\n",
      "eh\n",
      "0.049787068367863944\n",
      "3.209979588460643e-103\n",
      "eh\n",
      "eh\n",
      "0.049787068367863944\n",
      "4.344234967880666e-104\n",
      "eh\n",
      "eh\n",
      "0.01831563888873418\n",
      "1.598154732301378e-104\n",
      "eh\n",
      "eh\n",
      "0.0009118819655545162\n",
      "1.1808854971746377e-103\n",
      "eh\n",
      "eh\n",
      "4.5399929762484854e-05\n",
      "5.8792826982452694e-105\n",
      "eh\n",
      "eh\n",
      "0.0009118819655545162\n",
      "1.598154732301378e-104\n",
      "eh\n",
      "eh\n",
      "1.670170079024566e-05\n",
      "2.927122496515368e-106\n",
      "eh\n",
      "eh\n",
      "1.670170079024566e-05\n",
      "1.0768281882584307e-106\n",
      "eh\n",
      "eh\n",
      "1.670170079024566e-05\n",
      "3.961429521341682e-107\n",
      "eh\n",
      "eh\n",
      "0.049787068367863944\n",
      "7.9567438919514e-106\n",
      "eh\n",
      "eh\n",
      "0.00012340980408667956\n",
      "1.0768281882584307e-106\n",
      "eh\n",
      "eh\n",
      "0.0009118819655545162\n",
      "3.961429521341682e-107\n",
      "eh\n",
      "eh\n",
      "4.5399929762484854e-05\n",
      "3.961429521341682e-107\n",
      "eh\n",
      "eh\n",
      "0.00012340980408667956\n",
      "1.9722796241351285e-108\n",
      "eh\n",
      "eh\n",
      "1.670170079024566e-05\n",
      "9.819402048736065e-110\n",
      "eh\n",
      "eh\n",
      "0.049787068367863944\n",
      "2.6691902155412764e-109\n",
      "eh\n",
      "eh\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "({'AEP',\n",
       "  'BLK',\n",
       "  'BSX',\n",
       "  'CB',\n",
       "  'ED',\n",
       "  'INFO',\n",
       "  'IT',\n",
       "  'MKC',\n",
       "  'MO',\n",
       "  'SO',\n",
       "  'TRV',\n",
       "  'WEC'},\n",
       " {'AAL',\n",
       "  'AAP',\n",
       "  'AAPL',\n",
       "  'ABBV',\n",
       "  'ABC',\n",
       "  'ABT',\n",
       "  'ADBE',\n",
       "  'ADI',\n",
       "  'ADM',\n",
       "  'ADP',\n",
       "  'ADS',\n",
       "  'ADSK',\n",
       "  'AEP',\n",
       "  'AES',\n",
       "  'AFL',\n",
       "  'AGN',\n",
       "  'AIG',\n",
       "  'AIV',\n",
       "  'AIZ',\n",
       "  'AJG',\n",
       "  'AKAM',\n",
       "  'ALB',\n",
       "  'ALGN',\n",
       "  'ALK',\n",
       "  'ALL',\n",
       "  'ALLE',\n",
       "  'AMD',\n",
       "  'AMGN',\n",
       "  'AMP',\n",
       "  'AMT',\n",
       "  'ANSS',\n",
       "  'ANTM',\n",
       "  'APA',\n",
       "  'APD',\n",
       "  'APTV',\n",
       "  'ARE',\n",
       "  'ARNC',\n",
       "  'AVB',\n",
       "  'AVGO',\n",
       "  'AVY',\n",
       "  'AWK',\n",
       "  'AXP',\n",
       "  'AYI',\n",
       "  'AZO',\n",
       "  'BA',\n",
       "  'BAC',\n",
       "  'BBT',\n",
       "  'BBY',\n",
       "  'BEN',\n",
       "  'BIIB',\n",
       "  'BMY',\n",
       "  'BWA',\n",
       "  'BXP',\n",
       "  'C',\n",
       "  'CAH',\n",
       "  'CBOE',\n",
       "  'CBS',\n",
       "  'CCL',\n",
       "  'CELG',\n",
       "  'CERN',\n",
       "  'CF',\n",
       "  'CHRW',\n",
       "  'CI',\n",
       "  'CINF',\n",
       "  'CME',\n",
       "  'CMG',\n",
       "  'CMI',\n",
       "  'CNC',\n",
       "  'COF',\n",
       "  'COG',\n",
       "  'COO',\n",
       "  'COP',\n",
       "  'COST',\n",
       "  'COTY',\n",
       "  'CPB',\n",
       "  'CRM',\n",
       "  'CSCO',\n",
       "  'CTAS',\n",
       "  'CTL',\n",
       "  'CTXS',\n",
       "  'CVS',\n",
       "  'CVX',\n",
       "  'DFS',\n",
       "  'DG',\n",
       "  'DGX',\n",
       "  'DHI',\n",
       "  'DISCA',\n",
       "  'DLTR',\n",
       "  'DOV',\n",
       "  'DRE',\n",
       "  'DVA',\n",
       "  'DXC',\n",
       "  'EA',\n",
       "  'EFX',\n",
       "  'EL',\n",
       "  'EMR',\n",
       "  'EQT',\n",
       "  'ETFC',\n",
       "  'ETN',\n",
       "  'EXPD',\n",
       "  'EXPE',\n",
       "  'EXR',\n",
       "  'F',\n",
       "  'FAST',\n",
       "  'FB',\n",
       "  'FBHS',\n",
       "  'FCX',\n",
       "  'FE',\n",
       "  'FFIV',\n",
       "  'FLIR',\n",
       "  'FLS',\n",
       "  'FMC',\n",
       "  'GD',\n",
       "  'GE',\n",
       "  'GIS',\n",
       "  'GLW',\n",
       "  'GM',\n",
       "  'GPC',\n",
       "  'GRMN',\n",
       "  'HAL',\n",
       "  'HBI',\n",
       "  'HCA',\n",
       "  'HCP',\n",
       "  'HD',\n",
       "  'HES',\n",
       "  'HII',\n",
       "  'HOG',\n",
       "  'HOLX',\n",
       "  'HON',\n",
       "  'HPQ',\n",
       "  'HRB',\n",
       "  'HRL',\n",
       "  'HST',\n",
       "  'HUM',\n",
       "  'IBM',\n",
       "  'IFF',\n",
       "  'ILMN',\n",
       "  'INCY',\n",
       "  'INTC',\n",
       "  'IPG',\n",
       "  'IR',\n",
       "  'IRM',\n",
       "  'JBHT',\n",
       "  'JCI',\n",
       "  'JEC',\n",
       "  'JNPR',\n",
       "  'K',\n",
       "  'KIM',\n",
       "  'KMB',\n",
       "  'KMI',\n",
       "  'KMX',\n",
       "  'KR',\n",
       "  'KSS',\n",
       "  'L',\n",
       "  'LB',\n",
       "  'LEG',\n",
       "  'LEN',\n",
       "  'LH',\n",
       "  'LKQ',\n",
       "  'LLY',\n",
       "  'LNC',\n",
       "  'LUV',\n",
       "  'LYB',\n",
       "  'M',\n",
       "  'MAC',\n",
       "  'MAR',\n",
       "  'MAS',\n",
       "  'MAT',\n",
       "  'MCO',\n",
       "  'MET',\n",
       "  'MOS',\n",
       "  'MPC',\n",
       "  'MRK',\n",
       "  'MSI',\n",
       "  'MTB',\n",
       "  'MYL',\n",
       "  'NEM',\n",
       "  'NFLX',\n",
       "  'NKE',\n",
       "  'NLSN',\n",
       "  'NOV',\n",
       "  'NSC',\n",
       "  'NTAP',\n",
       "  'NUE',\n",
       "  'NWL',\n",
       "  'O',\n",
       "  'OKE',\n",
       "  'OMC',\n",
       "  'ORCL',\n",
       "  'ORLY',\n",
       "  'OXY',\n",
       "  'PAYX',\n",
       "  'PDCO',\n",
       "  'PEG',\n",
       "  'PFE',\n",
       "  'PH',\n",
       "  'PKG',\n",
       "  'PNR',\n",
       "  'PPG',\n",
       "  'PRGO',\n",
       "  'PSA',\n",
       "  'PSX',\n",
       "  'PVH',\n",
       "  'PXD',\n",
       "  'REG',\n",
       "  'RF',\n",
       "  'RHI',\n",
       "  'ROST',\n",
       "  'RSG',\n",
       "  'SBUX',\n",
       "  'SEE',\n",
       "  'SIG',\n",
       "  'SLB',\n",
       "  'SNPS',\n",
       "  'STX',\n",
       "  'STZ',\n",
       "  'SWK',\n",
       "  'SYMC',\n",
       "  'SYY',\n",
       "  'T',\n",
       "  'TAP',\n",
       "  'TGT',\n",
       "  'TIF',\n",
       "  'TROW',\n",
       "  'TSN',\n",
       "  'TXN',\n",
       "  'TXT',\n",
       "  'ULTA',\n",
       "  'UNH',\n",
       "  'UNM',\n",
       "  'UNP',\n",
       "  'UPS',\n",
       "  'URI',\n",
       "  'USB',\n",
       "  'UTX',\n",
       "  'VFC',\n",
       "  'VIAB',\n",
       "  'VMC',\n",
       "  'VNO',\n",
       "  'VRSK',\n",
       "  'VRTX',\n",
       "  'VZ',\n",
       "  'WDC',\n",
       "  'WHR',\n",
       "  'WLTW',\n",
       "  'WMT',\n",
       "  'WU',\n",
       "  'WY',\n",
       "  'XRAY',\n",
       "  'XRX',\n",
       "  'XYL',\n",
       "  'ZBH'})"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ramsey_R2_SA(G)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [],
   "source": [
    "def ramsey_R2_SA(G):\n",
    "    r\"\"\"Approximately computes the Ramsey number `R(2;s,t)` for graph.\n",
    "\n",
    "    Parameters\n",
    "    ----------\n",
    "    G : NetworkX graph\n",
    "        Undirected graph\n",
    "\n",
    "    Returns\n",
    "    -------\n",
    "    max_pair : (set, set) tuple\n",
    "        Maximum clique, Maximum independent set.\n",
    "    \"\"\"\n",
    "    \n",
    "    T = 1 #adjustable\n",
    "    \n",
    "    if not G:\n",
    "        return set(), set()\n",
    "\n",
    "    node = arbitrary_element(G)\n",
    "    nbrs = nx.all_neighbors(G, node)\n",
    "    nnbrs = nx.non_neighbors(G, node)\n",
    "    c_1, i_1 = ramsey_R2_SA(G.subgraph(nbrs).copy())\n",
    "    c_2, i_2 = ramsey_R2_SA(G.subgraph(nnbrs).copy())\n",
    "\n",
    "    c_1.add(node)\n",
    "    i_2.add(node)\n",
    "\n",
    "    if math.exp(-abs(len(c_1) - len(c_2))/T) > random.uniform(0,1):\n",
    "        return_c = min(c_1, c_2, key=len)\n",
    "    else:\n",
    "        return_c = max(c_1, c_2, key=len)\n",
    "    \n",
    "    if math.exp(-abs(len(i_1) - len(i_2))/T) > random.uniform(0,1):\n",
    "        return_i = min(i_1, i_2, key=len)\n",
    "    else:\n",
    "        return_i = max(i_1, i_2, key=len) \n",
    "    \n",
    "    return return_c, return_i"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
